package com.ipartek.formacion.threads;

public class ThreadExample extends Thread {
	@Override
	public void run() {

		for (int i = 0; i < 5; i++) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				System.out.println("Hilo detenido");
			}
			System.out.println("ejecuntando hilo");
		}
	}

	public static synchronized void escribreSync() {

		for (int i = 0; i < 10; i++) {
			System.out.println("Ejecutando hilo sincronizado");
		}

	}

	public static void escribre() {

		for (int i = 0; i < 10; i++) {
			System.out.println("Ejecutando hilo sincronizado");
		}

	}

	public static void main(String[] args) throws InterruptedException {

		ThreadExample hilo = new ThreadExample();
		hilo.setPriority(MAX_PRIORITY);
		hilo.start();

		for (int i = 5; i > 0; i--) {
			System.out.println("Otro proceso ejecuntandose " + i + "/5");
			Thread.sleep(1000);
		}

	}

}
